<h1>Présentation des salles du parc</h1>

<div id="page">
 
 <%  @salle.each_with_index do |salle, i| %>                                  

            <div id="group<%=i%>" class="section"> 
		<h3 class="handle"><%= salle.nomsalle %>  <% if authenticated? %>|<%= link_to 'Ajouter machine',  :controller => "machines", :action => "new", :salleid => salle.id  %>| <%end%></h3>
                <% for machine in salle.machine.each do %>
                <div id="item_<%= machine.id %>" class="lineitem" >
                 <img src="/images/machine.png" /> <%=machine.nommachine %>
                  <%=  hidden_field_tag machine.id, machine.id %>
                  <%= hidden_field_tag salle.id, salle.id  %>
                       <% if !machine.incidents.empty? %>
                       <span style="color:red">  <%= machine.ipmachine %> </span>
                       <a id="" href="javascript:void(0)" onclick="hideShow('m<%=machine.id%>')">Liste incidents</a>
                        <div id="m<%=machine.id%>" style="display: none">
                         
                         <%  for machines in machine.incidents.each do %>
                            <% if machines.etat == "a traiter" || machines.etat== "en cours" %>
                                <span style="color:red"> <%= machines.typeincident%> </span> --
                          <% else %>
                               <%= machines.typeincident%> --
                          <% end  %>
                         <% end %>
                        </div>
                     <%else%>
                       <%= machine.ipmachine %>
                    <%end%>                  
                        <% if authenticated? %> <%= link_to 'Supprimer', machine, :confirm => 'Etes vous sûr de vouloir supprimer cet enregistrement?', :method => :delete,:id=> machine.id%> <%end%>
                </div>
                <% end %>
            </div>
  <% end  %>

          
</div>

<script type="text/javascript">
	// <![CDATA[
    <% @salle.each_with_index do |salle, i| %>
     
	Sortable.create('group<%=i%>',{tag:'div',dropOnEmpty: true, containment: sections,only:'lineitem'});
	Sortable.create('page',{tag:'div',only:'section',handle:'handle'});
       
        
      <% end %>
	// ]]>
 </script>

<script type="text/javascript">
   function supprimer(id){
    document.location.href='/machines/destroy?id='+id;
   }
</script>